package com.demo.sa.service.impl;


import com.demo.sa.dao.SysUserDao;
import com.demo.sa.entity.SysUser;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import com.demo.sa.service.SysUserService;



/**
 * (SysUser)表服务实现类
 *
 * @author makejava
 * @since 2024-11-19 10:36:42
 */
@Service("sysUserService")
public class SysUserServiceImpl implements SysUserService {
    @Resource
    private SysUserDao sysUserDao;

    /**
     * 通过ID查询单条数据
     *
     * @param id 主键
     * @return 实例对象
     */
    @Override
    public SysUser queryById(Long id) {
        return this.sysUserDao.queryById(id);
    }



    /**
     * 新增数据
     *
     * @param sysUser 实例对象
     * @return 实例对象
     */
    @Override
    public SysUser insert(SysUser sysUser) {
        this.sysUserDao.insert(sysUser);
        return sysUser;
    }

    /**
     * 修改数据
     *
     * @param sysUser 实例对象
     * @return 实例对象
     */
    @Override
    public SysUser update(SysUser sysUser) {
        this.sysUserDao.update(sysUser);
        return this.queryById(sysUser.getId());
    }

    /**
     * 通过主键删除数据
     *
     * @param id 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long id) {
        return this.sysUserDao.deleteById(id) > 0;
    }

    public int count(SysUser sysUser) {
    	return (int) sysUserDao.count(sysUser);
    }

    public SysUser queryByNamePw(SysUser sysUser) {
    	return sysUserDao.queryByNamePw(sysUser);
    }
}
